<%--
  Created by IntelliJ IDEA.
  User: 4323434
  Date: 2024/11/24
  Time: 11:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.sql.*" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<%
    request.setCharacterEncoding("UTF-8");
    String bno=request.getParameter("bno");
    String bname=request.getParameter("bname");
    String author=request.getParameter("author");
    String publisher=request.getParameter("publisher");

    Class.forName("com.mysql.cj.jdbc.Driver");
    String url = "jdbc:mysql://localhost:3306/ts?serverTimezone=UTC";
    String username = "root";
    String password = "123456";

    // 建立连接
    Connection conn = DriverManager.getConnection(url, username, password);

    String sql=
            "update book set bname=?,author=?,publisher=? where bno=?";

    PreparedStatement ps=conn.prepareStatement(sql);
    ps.setString(1, bname);
    ps.setString(2, author);
    ps.setString(3, publisher);
    ps.setString(4, bno);
    int i=ps.executeUpdate();
    out.println("成功修改"+i+"行");
    ps.close();
    conn.close(); %>

</body>
</html>
